<template>
    <div>
    <el-form :inline="true" :model="candidate" class="demo-form-inline">
  <el-form-item label="姓名">
    <el-input v-model="candidate.name" placeholder="姓名"></el-input>
  </el-form-item>
  <el-form-item label="电话">
    <el-input v-model="candidate.phone" placeholder="电话号码"></el-input>
  </el-form-item>
  <el-form-item label="性别">
    <el-select v-model="candidate.gender" placeholder="性别">
      <el-option label="男" value="0"></el-option>
      <el-option label="女" value="1"></el-option>
    </el-select>
  </el-form-item>
  <el-form-item label="工种">
    <el-select v-model="candidate.occupationId" placeholder="工种">
      <el-option :label="item.name"  :value="item.id" v-for="(item,index) in occpationList" :key="index" ></el-option>
    </el-select>
  </el-form-item>
  <el-form-item>
    <el-button type="primary" @click="condition()">查询</el-button>
    <el-button icon="el-icon-delete" type="primary" @click="candidate={}">清空</el-button>
  </el-form-item>
</el-form>
        <!-- 表格 -->
<el-table
    :data="page.records"
    border
    style="width: 84.3%">
        <el-table-column
        prop="id"
        label="简历ID"
        width="100">
        </el-table-column>
        <el-table-column
        prop="name"
        label="姓名"
        width="160">
        </el-table-column>
        <el-table-column
        prop="phone"
        label="电话"
         width="160">
        </el-table-column>
        <el-table-column
        prop="wantSalary"
        label="期望薪资"
         width="100">
        </el-table-column>
          <el-table-column
        prop="wantSalary"
        label="性别"
         width="90">
         <template slot-scope="scope">
             {{scope.row.gender=='0'?'男':'女'}}
         </template>
        </el-table-column>
        <el-table-column
        prop="wantSalary"
        label="用户名"
         width="187">
         <template slot-scope="scope">
             {{scope.row.tbUser.username}}
         </template>
        </el-table-column>
          <el-table-column
        prop="occupationId"
        label="期望工种"
         width="138">
         <template slot-scope="scope">
             {{scope.row.tbOccupation!=null ? scope.row.tbOccupation.name:""}}
         </template>
        </el-table-column>
        <el-table-column
        prop="createTime"
        label="创建时间"
         width="180">
        </el-table-column>
  </el-table>

   <!-- 分页 -->
  <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="page.current"
      :page-sizes="[1, 10, 15, 20]"
      :page-size="page.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="page.total">
    </el-pagination>
    </div>
</template>

<script>
import {condition,findAllOccpation} from '@/api/candidates'
export default {
        data() {
            return {
                candidate:{
                    size:10,
                    current:1
                },
                page:{
                    size:10,
                    current:1,
                    total:0
                },
                occpationList:[]
            }
        },
        methods: {
            async condition(){
              console.log(this.candidate.occupationId)
                this.candidate.size = this.page.size
                 this.candidate.current = this.page.current
                let {data} = await condition(this.candidate)
                this.page = data
            },
            async findAllOccpation(){
                let {data} = await findAllOccpation();
                this.occpationList = data
            },
            handleSizeChange(val) {
            this.page.size  = val
            this.condition()
            },
            handleCurrentChange(val) {
                this.page.current = val
                this.condition()
            }
        },
        mounted() {
            this.condition()
            this.findAllOccpation()
        },
}
</script>

<style>

</style>